<style>
.mod-group {
    margin: 0 auto;
	margin-top: 5px;
    width: 94%;
    background-color: #fff;
    border-radius: 10px;
    border: 1px solid #f2f2f2;
}
.fui-icon-group .fui-icon-col-sm {
    margin:10px 0;
}
.badge {
    left: 2rem;
    top: 0;
}
.triangle {
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 5px solid #59bdbb;
	line-height:1;
 }
 .btn.btn-success{background:#F5F0FF}
.btn.btn-success, .jy-btn1{border-radius:1rem;background:linear-gradient(95.84deg, #EDF6FF 5.59%, #F0F3FF 51.42%, #F5F0FF 97.24%)}
.btn.btn-blue, .jy-btn2{border-radius:1rem;background:linear-gradient(136deg, #7783EA, #4e6ef2, #7274f9, #9f66ff)}
.jy-topbg{background:linear-gradient(to bottom, #f8dfd8, #F5F0FF, #F0F3FF, #f7f7f7)}
</style>
<div class='fui-page fui-page-current' ng-if="pagedata.op=='detail'" style="">
	<div class='fui-content' style="top:0;background: url('../addons/jy_aiagent/resource/images/aitexiao_bg.png') no-repeat 50%;background-size: cover;;padding-bottom:0">
		<div style="top:0;">
		<div class="c" style="color:#fff;padding:0;padding-top:1rem">
			<div style="padding-top:1rem;height:14rem;padding:0.5rem 3rem;margin:o auto" ng-include="sys_html('common/_texiao2')"></div>
			<div class="bold" style="font-size:0.85rem;padding-top:0.5rem">{{pagedata.issou==1?'加速扫描设备中...':'点击按钮开始搜索'}}</div>
			<div style="font-size:0.75rem;padding-top:0.5rem">
				<span ng-if="pagedata.issou==1">正在搜索，请尽可能将手机靠近设备</span>
				<span ng-if="pagedata.issou!=1">点击下面按钮，开始扫描附近的蓝牙设置</span>
			</div>
			<div ng-if="pagedata.issou!=1" class="weui_btn_area" style="padding: 1rem 2rem;">
				<a class="weui_btn weui_btn_primary bold" style="background:#17b5b2;color:#fff;" href="javascript:" id="scan-devices">开始扫描</a>
			</div>
		</div>
		<div ng-include="sys_html('common/_copyright',true)"></div>
	</div>
</div>
</div>
<div ng-if="pagedata.showsoufail" class="popup">
	<div class="popup-body">
		<div class="popup-center radius" style="width: 85%;">
		<div class="fui-cell-group" style="margin-top:1rem;-webkit-overflow-scrolling: touch;">
		<div class="bold" style="padding: 0 0.5rem;">设备扫描失败</div>
		<div class="fui-cell">
		<div class="fui-cell-text">
			<div class="text" style="line-height: 2;">
			<div>1.请确保手机开启蓝牙</div>
			<div>2.确保AI设备通电/开机(开启蓝牙)</div>
			<div>3.将手机尽量贴近设备</div>
			<div>4.若设备曾被其他手机连接过，请先断开连接。</div>
			<div>5.请确保已授权定位功能。</div>
			</div>
		</div>
		</div>
		</div>
		<div class="fui-cellone" style="padding-top:0.5rem">
					<div class="fui-cellone-text" style="padding-right:0.5rem">
					<div class="radius c" ng-click="access_json('jy_aiagent/index/')" style="background:#eaeef9;color:#3263fe;padding:0.5rem">
						关闭
					</div>
					</div>	
					<div class="fui-cellone-text">
					<div class="radius c" ng-click="pagedata.topeiblue()" style="background:#3263fe;color:#fff;padding:0.5rem">
						前往设置
					</div>
					</div>	
		</div>
		</div>
	</div>
</div>
<script>
scope.pagedata.jindu = 0;
scope.pagedata.showtexiao=true;
scope.pagedata.issou=1;
const scanDevicesBtn = document.getElementById('scan-devices');
setTimeout(()=>{  
 	console.log('停止');
	scope.pagedata.stoptexiao=true;
	scope.pagedata.issou=0;
	scope.pagedata.showsoufail=true;
	scope.$evalAsync();
}, 3000); 
scope.pagedata.topeiblue=function(){
	scope.message('请使用小程序配网！','error')
}
// 扫描设备
scanDevicesBtn.addEventListener('click', async () => {
            try {
                // 请求设备
                navigator.bluetooth.requestDevice({
                    filters: [{ services: [NETWORK_SERVICE_UUID] }],
                    optionalServices: [NETWORK_SERVICE_UUID]
                })
                .then(device => {
                    bluetoothDevice = device;
                })
                .catch(error => {
                });
            } catch (error) {
            }
});
</script>